/**
 * @file typeedition.c
 * @brief Fichier source du module typeedition.
 *
 * @author Rachid Delory, Mamadou Keita, Florian Bernard
 */

/* *********************************************************************

                       Librairies de typeedition                          

********************************************************************* */

#include "typeedition.h"

/* *********************************************************************

                        Fonctions                                      

********************************************************************* */

void init_Typ(TypeEdition * typeedition)
{
  if(typeedition)
    {
      typeedition->id = 0;
      typeedition->libelle = NULL;
      typeedition->maj = 0;
      typeedition->sup = 0;
    }
}

void liberer_Typ(TypeEdition * typeedition)
{
  if(typeedition)
    {
      typeedition->id = 0;
      if(typeedition->libelle)
	{
	  free(typeedition->libelle);
	  typeedition->libelle = NULL;
	}
    }
}

TypeEdition * creer_Typ()
{
  TypeEdition *typeedition;
  typeedition = (TypeEdition *) malloc ( 1 * sizeof(TypeEdition));
  init_Typ(typeedition);
  return typeedition;
}

void detruire_Typ(TypeEdition ** typeedition)
{
  if((*typeedition))
    {
      liberer_Typ((*typeedition));
      free((*typeedition));
      (*typeedition) = NULL;
    }
}

void copier_Typ(TypeEdition **dest, const TypeEdition *src)
{
  if(dest && src)
    {
      (*dest)->id = src->id;
      copier_Uti(&((*dest)->libelle), src->libelle);
    }
}
unsigned int getId_Typ(const TypeEdition * ptr)
{
  if(ptr)
    return ptr->id;
  return 0;
}

void setId_Typ(TypeEdition *ptr, const unsigned int val)
{
  if(ptr)
    ptr->id = val;
}

char * getLibelle_Typ(const TypeEdition * ptr)
{
  if(ptr)
    return ptr->libelle;
  return NULL;
}

void setLibelle_Typ(TypeEdition *ptr, const char * val)
{
  if(ptr)
    {
      copier_Uti(&(ptr->libelle), val);
    }
}

void setMaj_Typ(TypeEdition *ptr, const char b)
{
  if(ptr)
    {
      ptr->maj = b;
      if(b == 1)
	ptr->sup = !b;
    }
}

char getMaj_Typ(const TypeEdition *ptr)
{
  if(ptr)
    return ptr->maj;
  return 0;
}

void setSup_Typ(TypeEdition *ptr, const char b)
{
  if(ptr)
    {
      ptr->sup = b;
      if(b == 1)
	ptr->maj = !b;
    }
}

char getSup_Typ(const TypeEdition *ptr)
{
  if(ptr)
    return ptr->sup;
  return 0;
}
